<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>判断是否是PE恶意软件</title>
<link rel="stylesheet" href="../styles/style.css" type="text/css" />
<link rel="stylesheet" href="../styles/table.css" type="text/css" />
<script src="../script/common.js"></script>
<script type="text/javascript">
$import("rpc.js");
$import("table_list_without_page_control_bar.js");

var status = null;
var completed = false;
var trainSetId = null;

/** 1.提交，检查输入 */
function onSubmit()
{
	completed = false;
	status = null;
	if ($("testfile").value == "")
	{
		alert("请选择要判断的样本文件！");
		return;
	}
	if ($("trainSet").value == "")
	{
		alert("请选择要使用的训练集！");
		return;
	}

	var callback = function()
	{
		$("fileForm").submit();
		check();				//检查文件上传进度，完成后开始PE文件分析
	}
	$("progress").style.display = "";

	var operation = new Operation("文件.准备上载文件");
	operation.path = "";
	operation.execute(callback);
}

/** 2.检查上载进度 */
function check()
{
	var callback = function (result)
	{
		if (completed) return;

		status = result.status;
		if (status != null)
		{
			if (status.aborted)
			{
				completed = true;
				alert("上载被取消: " + status.reason);
				status = null;
				return;
			}
			if (status.completed)
			{
				completed = true;
				status = null;
				createResult();
				return;
			}
		}
		setTimeout(check, 1000);
	}
	
	var operation = new Operation("文件.获取上载进度");
	operation.execute(callback);
}

/** 3.创建判断结果 */
function createResult()
{

	var titles = 
	[
		{text:"文件名", width:"40%"},
		{text:"判断结果", width:"40%"}
	];
	var columns =  
	[
		function(data) { return data.name; },
		function(data)
		{ 
			showResult();
			var img = document.createElement("span");
			img.innerHTML = '<img src="../images/' + data.result + '.gif"/>';
			return img;
		}
	];    
	var operation = new Operation("PE分析.判断文件是否是PE恶意软件");
	operation.name = $("testfile").value;
	operation.trainSetId = trainSetId;
	var tableList = new TableList(operation, titles, columns);
	tableList.create($("container"));
	tableList.refresh();
}

/** 4.显示判断结果 */
function showResult()
{
	$("progress").style.display = "none";
	$("result").style.display = "";
}

function selectTrainSet()
{
	var result = window.showModalDialog("trainSet_select.html", null, "dialogWidth=800px;dialogHeight=600px");
	if (result == null)
	    return ;
	else
	{
		$("trainSet").value = result.name;
		trainSetId = result.id;
	}
}
</script>

</head>
<body>
<div id="ur_here"><img src="../images/icon_here.gif" style="align:absmiddle" align="absmiddle"/> 当前位置：首页 » 判断是否是PE恶意软件 </div>
<div id="wrap">
<div id="containaer" >
	<div id="title" class="title">判断是否是PE恶意软件</div>
	<div class="filter" id="testFile_div">
		<div class="filterTitle">
		<table cellpadding=0 cellspacing=0 border=0 width="100%" style="border-right:1px solid #A7B9CF;">
			<tr class='tablecell'>
				<td class='tit' width="20%"><span style="color:red">*</span>选择分析文件</td>
				<td class='inp'>
					<form id="fileForm" name="fileForm" action = "../upload" method="post" enctype="multipart/form-data" target="upload_result">
						<input id="testfile" name="testfile" type="file" size="40"/>
						<span style="color:red">&nbsp;&nbsp;*单个文件直接上传分析，多个文件请打包为zip格式上传分析</span>
					</form> 
					<iframe name="upload_result" id="upload_result" style="display:none"></iframe>
				</td>
			</tr>
			<tr class='tablecell'>
				<td class='tit' width="20%"><span style="color:red">*</span>选择训练集</td>
				<td class='inp'>
					<input id="trainSet" disabled="disabled" type="text"/>
					<input id="trainSetSelect" type="button" value="选择训练集" onclick="selectTrainSet()"/>
				</td>
			</tr>
		</table>
		</div>
		<div class="filterInput" style="padding:2px 0px 0px 25px;">
			<input type="button" class="form_judge" onClick="onSubmit()"/>
			<span id="progress" style="display:none">判断中...<img src="../images/loading.gif" align="absmiddle"></span>
		</div>
		<div class="clear"></div>
		<div class="title" id="result" style="display:none">
			判断结果如下！
		</div>
	</div>
	
	<!-- 结果展示div -->
	<div id="container"></div>
</div>
</div>
</body>
</html>